$(document).ready(function(){
   var uid= $("input[name=uid]").val();
   console.log(uid);
  if( uid==0 ){
    location.href="member.php?mod=logging&action=login";
  }

 $('.message .submit').click(function(){
     var phone=$("input[name=phone]").val();
     var flag = false;
      var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0]{1})|(15[0-3]{1})|(15[5-9]{1})|(18[0-9]{1}))+\d{8})$/;       
      if(phone == ''){
        alert("手机号码不能为空！") ;
      }else if(phone.length !=11){
        alert( "请输入有效的手机号码！");
      }else if(!myreg.test(phone)){
       alert("请输入有效的手机号码！");
       }else if(checkPhoneIsExist( phone)){
         location.href="plugin.php?id=annual:talk";
		 
      }else{
        qiandao();
      	var _this = this;
        $('.layout-box').fadeToggle('slow', function() {
        _this.time = setTimeout(function(){
          $('.layout-box').fadeToggle('slow');
        },3000)
        location.href="plugin.php?id=annual:talk";
       }); 
         flag = true;
      }
     return flag;   
  });


   function  qiandao(){
         var uid=$('input[name=uid]').val();
         var name=$('input[name=name]').val();
         jQuery.ajax(
          { url: "plugin.php?id=annual:verify",
            data:{news:'签到成功~',action:'talk',uid:uid,name:name},
            dataType:"json",
               type:"POST",
               async:false,
        });   
    }

    function checkPhoneIsExist( phone){ 
         var uid=$('input[name=uid]').val();
         var name=$('input[name=name]').val(); 
         var flag = true;
         jQuery.ajax(
          { url: "plugin.php?id=annual:verify",
            data:{phone:phone,action:'verify',uid:uid,name:name},
            dataType:"json",
               type:"POST",
               async:false,
               success:function(data) {
               	console.log(data);
               if(data == "1"){
                 flag = false;
               }
             }
        });
        return flag;
       }

});	
